<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>绑定维保</title>
    <meta name="keywords" content="Bootstrap模版,Bootstrap模版下载,Bootstrap教程,Bootstrap中文" />
    <meta name="description" content="站长素材提供Bootstrap模版,Bootstrap教程,Bootstrap中文翻译等相关Bootstrap插件下载" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />

    <!-- basic styles -->

    <link href="assets/css/bootstrap.min.css" rel="stylesheet" />
    <link rel="stylesheet" href="assets/css/font-awesome.min.css" />
    <link rel="stylesheet"  href="assets/css/kkpager_orange.css" />
    <link rel="stylesheet"  href="assets/css/MyCss.css" />

    <!--[if IE 7]>
    <link rel="stylesheet" href="assets/css/font-awesome-ie7.min.css" />
    <![endif]-->

    <!-- page specific plugin styles -->

    <!-- ace styles -->

    <link rel="stylesheet" href="assets/css/ace.min.css" />
    <link rel="stylesheet" href="assets/css/ace-rtl.min.css" />
    <link rel="stylesheet" href="assets/css/ace-skins.min.css" />
    <link rel="stylesheet"  href="assets/css/jquery.datetimepicker.css" />

    <!--[if lte IE 8]>
    <link rel="stylesheet" href="assets/css/ace-ie.min.css" />
    <![endif]-->

    <!-- inline styles related to this page -->

    <!-- ace settings handler -->

    <script src="assets/js/ace-extra.min.js"></script>
    <script src="/resources/jquery/jquery-2.2.3.min.js"></script>
    <script src="/resources/jquery.datetimepicker1.js"></script>

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <style>
        .panel-heading
        {
            position: relative;
        }
        .map
        {
            position: absolute;
            top:20%;
            right: 10px;
        }
    </style>
    <!--[if lt IE 9]>
    <script src="assets/js/html5shiv.js"></script>
    <script src="assets/js/respond.min.js"></script>
    <![endif]-->
</head>

<body >
<#include "header.ftl"/>
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try{ace.settings.check('main-container' , 'fixed')}catch(e){}
    </script>

<div class="main-container-inner">
    <a class="menu-toggler" id="menu-toggler" href="#">
        <span class="menu-text"></span>
    </a>


<#include "left_list_menu.ftl">
<div class="main-content">
<div class="breadcrumbs" id="breadcrumbs">
    <script type="text/javascript">
        try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
    </script>
    <ul class="breadcrumb">
        <li>
            <i class="icon-home home-icon"></i>
            客户管理
        </li>

        <li>
            <a href="selectCustomerList?page=1">客户信息列表</a>
        </li>
        <li>
            客户信息详情
        </li>
    </ul><!-- .breadcrumb -->

</div>
<div class="page-content">




<#if baseInsurance??>

<table border="1" align="center">

    <tr>
        <th>维保名</th>

        <th>维保状态</th>

        <th>维保到期时间</th>

        <th>维保类型</th>

        <th>时间1</th>

        <th>时间2</th>
    </tr>



    <tbody>
    <#list baseInsurance as ins>

<form action="insertOrUpdateInsurance" method="post" class="formm" onsubmit="return update()">
    <tr>
        <td>
            <input type="text" class="id" name="id" value="${ins.id !""}" hidden="hidden">
            <input type="text" name="address_id" class="address_id" value="${ins.address_id !""}" hidden="hidden">
            <input type="text" name="name" class="name" value="${ins.name !""}" readonly="readonly"/>
        </td>
        <td>
            <select style="width:150px" id="vrv" name="status" class="sel">
                <#if "${ins.status !''}"=="1">
                    <option value="1">有</option>
                    <option value="0">无</option>
                <#else>
                    <option value="0">无</option>
                    <option value="1">有</option>
                </#if>
            </select>
        </td>
        <td>
            <input type="date" <#--class="form-control"-->class="lastTime" placeholder="请选择到期时间" required min="2017-07-20" <#--id="date"--> value="${ins.lastDate !""}"  name="lastDate"/>
        </td>
        <td>
            <input type="text" name="type" class="type" value="${ins.type !""}" readonly="readonly"/>
        </td>
        <td>
            <label id="time1" style="width: 120px"><#if ins.firstTime??>${ins.firstTime?number_to_date}<#else >日期暂无</#if></label>
        </td>
        <td>
            <label id="time2" style="width: 120px"><#if ins.secondTime??>${ins.secondTime?number_to_date}<#else >日期暂无</#if></label>
        </td>

    </tr>
</form>






</#list >

    <button type="button" class="btn btn-primary btn-xs" id="saveCustomerInfo" style="float: right;margin-top:-6px;" onclick="return update()"> 保 存 </button>

</tbody>
</table>

</div>


</div>
</div>
</div>

    <a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
        <i class="icon-double-angle-up icon-only bigger-110"></i>
    </a>


<script type="text/javascript">
    window.jQuery || document.write("<script src='assets/js/jquery-2.0.3.min.js'>"+"<"+"/script>");
</script>



<script type="text/javascript">
    if("ontouchend" in document) document.write("<script src='assets/js/jquery.mobile.custom.min.js'>"+"<"+"/script>");
</script>
<script type="text/javascript" src="assets/js/jquery-1.10.2.min.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
<script src="assets/js/typeahead-bs2.min.js"></script>

<!-- page specific plugin scripts -->

<script src="assets/js/jquery.dataTables.min.js"></script>
<script src="assets/js/jquery.dataTables.bootstrap.js"></script>

<!-- ace scripts -->

<script src="assets/js/ace-elements.min.js"></script>
<script src="assets/js/ace.min.js"></script>

<script type="text/javascript" src="assets/js/kkpager.min.js"></script>
<script src="assets/js/myJs.js"></script>
<script src="assets/js/jquery.datetimepicker.js"></script>

<!-- inline scripts related to this page -->

<script src="assets/js/jquery.cookie.js"></script>
<script type="text/javascript">
    window.onload=function(){
        var name = $.cookie('username');
        if (name == '' || name == null || typeof(name)=="undefined"){
            document.getElementById("user_name").innerText="unknown user";
            alert("请先登录");
            window.location.href='login';
        }

        document.getElementById("user_name").innerText=name;
    }


    $('[data-rel="tooltip"]').tooltip({placement: tooltip_placement});
    function tooltip_placement(context, source) {
        var $source = $(source);
        var $parent = $source.closest('table')
        var off1 = $parent.offset();
        var w1 = $parent.width();

        var off2 = $source.offset();
        var w2 = $source.width();

        if( parseInt(off2.left) < parseInt(off1.left) + parseInt(w1 / 2) ) return 'right';
        return 'left';
    }


    </script>


<script type="text/javascript">
 window.jQuery || document.write("<script src='assets/js/jquery-1.10.2.min.js'>"+"<"+"/script>");
</script>
</#if>
        <script type="text/javascript">



        </script>
        <script type="text/javascript">

        function update() {



            var ids = document.getElementsByClassName("id");
            var forms = document.getElementsByClassName("formm");
            var sel = document.getElementsByClassName("sel");
            var last = document.getElementsByClassName("lastTime");
            var names = document.getElementsByClassName("name");
            var types = document.getElementsByClassName("type");
            var address_ids = document.getElementsByClassName("address_id");
            for (var i = 0; i < forms.length; i++) {

                if(sel[i].value==1 && (last[i].value==null||last[i].value=="")) {

                    alert("请选择到期时间！")
                    return false
                }

            }

            for (var i = 0; i < forms.length; i++) {

                $.ajax({
                    type:"POST",
                    url:"insertOrUpdateInsurance?",
                    data:{"id" : ids[i].value,"name" : names[i].value,"status" : sel[i].value,"type" : types[i].value,"address_id" : address_ids[i].value,"lastDate" : last[i].value},
                    // dataType:'json',
                    success:function(msg){
                        if(msg.status == 200){

                            // alert(msg);
                            //window.location.reload();
                        }/*else{
                            alert("修改失败！");
                            return false;
                        }*/
                    },
                    error: function () {
                        alert("服务端出错！");
                        // window.location=localhost/getInsuranceByAddress_id?address_id=id
                        return false;
                    }
                });

                if(i==forms.length-1){
                    alert("修改成功！")
               reload()
                    return true;
                }

            }






            }


            function reload() {
                setTimeout("window.location.reload()",500)

            }








        </script>

</body>
</html>